package com.ruoyi.common.utils.excl.export;

import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import org.apache.commons.lang3.StringUtils;

public class CustomExportService extends ExcelExportService {

    @Override
    public Object getCellValue(ExcelExportEntity entity, Object obj) throws Exception {
        String numFormat = entity.getNumFormat();
        String newFormat = null;
        if (StringUtils.isNotEmpty(numFormat)) {
            if (entity.getNumFormat().startsWith("format:")) {
                newFormat = numFormat.substring(6, numFormat.length() - 1);
            }
        }
        entity.setNumFormat(newFormat);
        Object cellValue = super.getCellValue(entity, obj);
        entity.setNumFormat(numFormat);
        return cellValue;
    }
}
